<?php
/*
 * @author : Pham Huu Sam
 * @phone : 0922.926.269
 */
class Config extends CI_Controller{
    //put your code here

    public function  __construct() {
        parent::__construct();
        $this->load->helper("url");
        $this->load->library("admin_layout"); // Sử dụng thư viện layout
        $this->admin_layout->setLayout("layout/admin"); // load file layout chính (view/layout/frontend.php)
        $this->load->Model('Mconfig');
        $this->load->helper(array('form', 'url'));
        $this->load->library('form_validation');
    }

    // Controller mặc định cho trang chủ
    public function index(){
        $data['title'] = 'Cài đặt';
        $data['data']=$this->Mconfig->get_One();
        

        $data['msg']='';
        $config = array(
            array(
                 'field'   => 'pagesize', 
                 'label'   => 'Số Trang', 
                 'rules'   => 'numeric'
            )
        );

        $this->form_validation->set_rules($config);
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');

        if ($this->form_validation->run() == FALSE)
        {
           $this->admin_layout->view("admin/config",$data);
        } else {            
            
            $data_edit = array(
               'cf_PageSize' => $this->input->post('pagesize')
            );

            $this -> Mconfig -> editConfig($data_edit);

            redirect('admin/config');
           
        }
    }
}
?>
